package it.e80.nm.bpm.view.converters;

import it.e80.nm.bpm.model.ProjectStatus;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.omg.PortableInterceptor.ACTIVE;

public class ProjectStatusConverter  implements Converter, ProjectStatus  {

    
    public ProjectStatusConverter() {
        super();
    }

    public Object getAsObject(FacesContext facesContext,
                              UIComponent uIComponent, String string) throws javax.faces.convert.ConverterException {
        if ((""+ACTIVE).equals(string)) return "Attivo";
        if ((""+REMOVED).equals(string)) return "Rimosso";
        if ((""+UNKNOWN).equals(string)) return "Non definito";
        return "";
    }

    public String getAsString(FacesContext facesContext,
                              UIComponent uIComponent, Object object) throws javax.faces.convert.ConverterException {
        if (!(object instanceof oracle.jbo.domain.Number)) return "";
        oracle.jbo.domain.Number n = (oracle.jbo.domain.Number)object;
        if (ACTIVE == n.intValue()) return "Attivo";
        if (REMOVED == n.intValue()) return "Rimosso";
        if (UNKNOWN == n.intValue()) return "Non definito";
        return "";
    }
}
